/* 
 * File:   z3d_mesh_test.h
 * Author: ferranferri
 *
 * Created on June 6, 2013, 5:27 PM
 */

#pragma once
#ifndef Z3D_MESH_TEST_H
#define	Z3D_MESH_TEST_H

#include <gtest/gtest.h>
#include "z3d/graphics/geometry/geometry.h"

class Z3D_mesh_testFixture: public ::testing::Test {

    public:
    float* _vertexData;
    virtual void SetUp() {
        float vertexData[] = {
         //  X     Y     Z
         0.0f, 0.8f, 0.0f,
        -0.8f,-0.8f, 0.0f,
         0.8f,-0.8f, 0.0f,
    };
        _vertexData = new float[9];

        std::copy(vertexData, vertexData + 9, _vertexData);
    }
    
    virtual void TearDown() {
        delete[] _vertexData;
    }
};


TEST_F(Z3D_mesh_testFixture, Z3D_mesh_ctor_you_set_name_in_ctor) {
    z3d::Z3D_Mesh mesh("myMesh");
    ASSERT_EQ("myMesh", mesh.getName());
}

TEST_F(Z3D_mesh_testFixture, Z3D_mesh_ctor_you_can_change_the_name_with_setter) {
    z3d::Z3D_Mesh mesh("myMesh");
    mesh.setName("myOtherName");
    ASSERT_EQ("myOtherName", mesh.getName());
}

TEST_F(Z3D_mesh_testFixture, Z3D_mesh_setVertices_copies_the_contents_in_vector) {
    z3d::Z3D_Mesh mesh("M");
    std::vector<float> v(_vertexData, _vertexData + 9);

    mesh.setVertices(v);
    ASSERT_EQ(v[0], mesh.vertexAt(0));
    ASSERT_EQ(v[1], mesh.vertexAt(1));
    ASSERT_EQ(v[2], mesh.vertexAt(2));
    ASSERT_EQ(v[3], mesh.vertexAt(3));
}

#endif	/* Z3D_MESH_TEST_H */

